﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using WPControla.Client.ViewModels.Base;
using WPControla.Client.Services;

namespace WPControla.Client.ViewModels
{
    public class VMViewChapter : VMBase, IVMViewChapter
    {
        private IAudioService AudioService;

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="audioService">audio playing service</param>
        public VMViewChapter(IAudioService audioService)
        {
            AudioService = audioService;
        }

        Entities.PodcastItem item;
        /// <summary>
        /// Selected chapter
        /// </summary>
        public Entities.PodcastItem Item 
        {
            get
            {
                return item;
            }
            set
            {
                item = value;
                RaisePropertyChanged(() => Item);
            }
        }

        private ICommand previewAudioCommand;
        /// <summary>
        /// This command preview the podcast chapter.
        /// </summary>
        public ICommand PreviewAudioCommand
        {
            get
            {
                if (previewAudioCommand == null)
                    previewAudioCommand = new DelegateCommand(ExecutePreviewAudioCommand, null);
                return previewAudioCommand;
            }
        }

        /// <summary>
        /// This method executes the command action.
        /// </summary>
        public void ExecutePreviewAudioCommand()
        {
            AudioService.PreviewTrack(Item);
        }
    }
}
